<script>
	import moment from 'moment';
	export default {
		onLaunch: function(e) {

			//转发链接
			if (e.query && e.query.inviter) {
				uni.setStorageSync('inviter', e.query.inviter);
			}

			// console.log('App Show');
			uni.onPushMessage((res) => {
				// console.log('收到推送消息：', res); //监听推送消息
				let temp = uni.getStorageSync('pralldata');
				let operatingTimeStart = temp.operatingTimeStart;
				let operatingTimeEnd = temp.operatingTimeEnd;
				const startTime = moment(operatingTimeStart, 'HH:mm');
				const endTime = moment(operatingTimeEnd, 'HH:mm');
				// 获取当前时间
				const currentTime = moment();
				// 将当前时间的日期部分设置为与开始时间相同
				currentTime.set({
					year: startTime.year(),
					month: startTime.month(),
					date: startTime.date()
				});
				// 判断当前时间是否在开始时间和结束时间之间
				const isBetween = currentTime.isBetween(startTime, endTime, null, '[]');
				if (true) {
					let temps = res.data.payload.type;
					// console.log('消息类：', temps);
					switch (temps) {
						case 1: {
							console.log('1');
							uni.createPushMessage({
								content: '上报（每日防火巡查记录）时间到，请及处理'
							});
							break;
						}
						case 2: {
							console.log('2');
							uni.createPushMessage({
								content: '上报（灭火器安全检查记录表）时间到，请及处理'
							});
							break;
						}
						case 3: {
							console.log('3');
							uni.createPushMessage({
								content: '上报（消防控制室值班记录表）时间到，请及处理'
							});
							break;
						}
						case 4: {
							console.log('4');
							uni.createPushMessage({
								content: '上报（消防栓检查表）时间到，请及处理'
							});
							break;
						}
						case 5: {
							console.log('5');
							uni.createPushMessage({
								content: '上报（建筑消防设施维护保养和故障维修记录表）时间到，请及处理'
							});
							break;
						}
						case 6: {
							console.log('6');
							uni.createPushMessage({
								content: '上报（专职、义务消防队人员记录表）时间到，请及处理'
							});
							break;
						}
						case 7: {
							console.log('7');
							uni.createPushMessage({
								content: '上报（灭火和应急疏散预案演练记录表）时间到，请及处理'
							});
							break;
						}
						case 8: {
							console.log('8');
							uni.createPushMessage({
								content: '上报（年度消防经费开支统计记录表）时间到，请及处理'
							});
							break;
						}
						case 9: {
							console.log('9');
							uni.createPushMessage({
								content: '上报（动用明火记录表）时间到，请及处理'
							});
							break;
						}
						case 10: {
							console.log('10');
							uni.createPushMessage({
								content: '上报（消防监控室制表记录表）时间到，请及处理'
							});
							break;
						}
						case 11: {
							console.log('11');
							uni.createPushMessage({
								content: '上报（消防安全宣传培训记录表）时间到，请及处理'
							});
							break;
						}
						case 12: {
							console.log('12');
							uni.createPushMessage({
								content: '上报（消防检查整改记录表）时间到，请及处理'
							});
							break;
						}
						case 13: {
							console.log('13');
							uni.createPushMessage({
								content: '上报（消防设施管理表）时间到，请及处理'
							});
							break;
						}
						case 14: {
							console.log('14');
							uni.createPushMessage({
								content: '上报（消防安全日查记录表）时间到，请及处理'
							});
							break;
						}
						case 15: {
							console.log('15');
							uni.createPushMessage({
								content: '上报（消防定期检查记录表）时间到，请及处理'
							});
							break;
						}
						case 16: {
							console.log('16');
							uni.createPushMessage({
								content: '上报（消防测试记录表）时间到，请及处理'
							});
							break;
						}
						case 17: {
							console.log('17');
							uni.createPushMessage({
								content: '上报（消防系统验收表）时间到，请及处理'
							});
							break;
						}
						case 18: {
							console.log('18');
							uni.createPushMessage({
								content: '上报（消防维保交接清单）时间到，请及处理'
							});
							break;
						}
						case 19: {
							// console.log('19');
							uni.createPushMessage({
								content: res.data.content
							});

							let type = res.data.payload.msgType;
							let title = res.data.title;
							let content = res.data.content;
							let id = res.data.payload.id;
							let time = res.data.payload.time;
							let imgUrl = res.data.payload.imgUrl;
							let position = res.data.payload.position;
							let nature = res.data.payload.nature //性质
							let reason = res.data.payload.reason //性质
							let isRead = false;

							// console.log('位置：', position);

							let msg = {
								type: type,
								title: title,
								content: content,
								id: id,
								time: time,
								isRead: isRead,
								imgUrl: imgUrl,
								position: position,
								nature: nature,
								reason: reason
							};



							let msgs = uni.getStorageSync('msgs');

							if (!msgs) {
								let arr = new Array();
								arr.push(msg);
								msgs = arr;
							} else {
								for (let m in msgs) {
									if (msgs[m].id == msg.id) {
										return
									}
								}

								msgs.push(msg);
							}

							msgs.sort((a, b) => {
								// 将时间字符串转换为日期对象进行比较
								let dateA = new Date(a.time);
								let dateB = new Date(b.time);
								// 返回比较结果
								return dateB - dateA;
							})
							// console.log(msgs)
							uni.setStorageSync('msgs', msgs);
							break;
						}
						default: {
							console.log('默认');
							break;
						}
					}
				} else {
					// console.log('传入的时间不在开始时间和结束时间之间');
				}
				// console.log(currentTime);
			});

			// #ifdef APP
			plus.push.addEventListener("receive", function(msg) {
				//plus.nativeUI.alert(JSON.stringify(msg));
				receiveData(msg, '2');
			}, false);
			// #endif


			let receiveData = function(msg, num) {
				if (uni.getSystemInfoSync().platform == 'ios') {
					if (msg.type == "receive") {
						// console.log(msg)
						//创建本地消息,发送的本地消息也会被receive方法接收到，
						plus.push.createMessage(msg.content, JSON.stringify(msg), {
							title: msg.title
						});
					}
				}
			}


		},
		onShow: function() {},
		onHide: function() {
			// console.log('App Hide')
		}
	};
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uview-plus/index.scss';
	@import '@/custom/custom.css';
	@import url('common/uni.css');

	.com_add_btn {
		position: fixed;
		right: 10rpx;
		bottom: 20%;
		border-radius: 50%;
		background: #49A0FF;
		color: #fff;
		width: 100rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 999;
	}

	/* 解决小程序和app滚动条的问题 */
	/* #ifdef MP-WEIXIN || APP-PLUS */
	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}

	/* #endif */

	/* 解决H5 隐藏滚动条的问题 */
	/* #ifdef H5 */
	uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
		/* 隐藏滚动条，但依旧具备可以滚动的功能 */
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}

	/* #endif */
	.overflow_x_auto {
		overflow-x: auto;
		white-space: nowrap;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}

	.overflow_auto {
		overflow-x: auto;
		white-space: nowrap;
	}

	// 苹果x顶部
	.iphonex_box {
		padding-bottom: 200rpx;
	}

	// 底部固定(适配苹果x)
	.com_footer_fixed {
		height: 150rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		padding-bottom: 0;
		padding-top: 20rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	// 默认样式
	button {
		position: relative;
		display: block;
		margin-left: auto;
		margin-right: auto;
		box-sizing: border-box;
		font-size: 18px;
		text-align: center;
		text-decoration: none;
		line-height: 1;
		border-radius: 5px;
		-webkit-tap-highlight-color: transparent;
		overflow: hidden;
		background-color: #fff;
	}

	// 边框样式
	button::after {
		border: 0;
	}

	// 禁用时样式
	button[disabled] {
		background-color: #fff;
		color: #666;
	}

	// 点击时样式
	.button-hover {
		color: rgba(0, 0, 0, 0.6);
		background-color: #fff;
	}

	.com_btn {
		background: #49A0FF;
		color: #ffffff;
		padding: 14rpx 40rpx;
		font-size: 28rpx;
		border-radius: 9rpx;
	}

	/****************背景色******************/
	page {
		background: #fff;
	}

	//白色
	.bg_fff {
		background: #fff;
	}

	// 主色
	.bg_all {
		background: #337eff;
		color: #ffffff;
	}

	// 危险
	.bg_risk {
		background: #f24957;
		color: #ffffff;
	}

	// 成功
	.bg_success {
		background: #26bd71;
		color: #ffffff;
	}

	// 警告
	.bg_warning {
		background: #ffaf0f;
		color: #ffffff;
	}

	/****************阴影******************/
	.box_shadow_xl {
		box-shadow: 0rpx 0rpx 60rpx 0rpx rgba(0, 0, 0, 0.1);
	}

	.box_shadow_normal {
		box-shadow: 0rpx 0rpx 60rpx 0rpx rgba(0, 0, 0, 0.1);
	}

	.box_shadow_l {
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.1);
	}

	.box_shadow_s {
		box-shadow: 0rpx 0rpx 40rpx 0rpx rgba(0, 0, 0, 0.1);
	}

	.box_shadow_m {
		box-shadow: 0rpx 0rpx 40rpx 0rpx rgba(0, 0, 0, 0.1);
	}

	/****************文字颜色******************/
	.color_all {
		color: #337eff;
	}

	.color_normal {
		color: #666666;
	}

	.color_l {
		color: #999999;
	}

	.color_m {
		color: #CCCCCC;
	}

	.color_fff {
		color: #FFFFFF;
	}

	.color_res {
		color: red;
	}

	/****************边框颜色******************/
	.border_top_normal {
		border-top: 1rpx solid #EEEEEE;
	}

	.border_bottom_normal {
		border-bottom: 1rpx solid #EEEEEE;
	}

	.border_right_normal {
		border-right: 1rpx solid #EEEEEE;
	}

	.border_left_normal {
		border-left: 1rpx solid #EEEEEE;
	}

	// 0.5下边框
	.border-gradient:after {
		content: ' ';
		position: absolute;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 1px;
		background-image: linear-gradient(0deg, #EEEEEE 50%, transparent 50%);
	}

	/****************position******************/
	.position_absolute {
		position: absolute;
	}

	.position_relative {
		position: relative;
	}

	.position_static {
		position: static;
	}

	.position_fixed {
		position: fixed;
	}

	/****************line_height******************/
	.line_height_xxxl {
		line-height: 45rpx;
	}

	.line_height_xxl {
		line-height: 40rpx;
	}

	.line_height_xl {
		line-height: 35rpx;
	}

	.line_height_normal {
		line-height: 30rpx;
	}

	.line_height_l {
		line-height: 25rpx;
	}

	.line_height_m {
		line-height: 20rpx;
	}

	/****************缩进******************/
	.text_indent_normal {
		text-indent: 44rpx;
	}

	/****************缩放******************/
	.scale_xxxl {
		transform: scale(1.8);
	}

	.scale_xxl {
		transform: scale(1.5);
	}

	.scale_xl {
		transform: scale(1.3);
	}

	.scale_l {
		transform: scale(0.8);
	}

	.scale_m {
		transform: scale(0.5);
	}

	.scale_s {
		transform: scale(0.3);
	}

	/****************文字大小******************/
	.font_big_xl {
		font-size: 100rpx;
	}

	.font_big {
		font-size: 168rpx;
	}

	.font_big_l {
		font-size: 44rpx;
	}

	.font_xxxl {
		font-size: 40rpx;
	}

	.font_xxl {
		font-size: 36rpx;
	}

	.font_xl {
		font-size: 34rpx;
	}

	.font_normal {
		font-size: 30rpx;
	}

	.font_l {
		font-size: 26rpx;
	}

	.font_m {
		font-size: 24rpx;
	}

	.font_s {
		font-size: 18rpx;
	}

	/****************标题栏ICON尺寸******************/
	.app_nav_icon {
		width: 36rpx;
		height: 36rpx;
	}

	/****************列表ICON尺寸******************/
	.app_list_icon {
		width: 38rpx;
		height: 38rpx;
	}

	/****************圆角******************/
	.border_radius_circle {
		border-radius: 50%;
	}

	.border_radius_xl {
		border-radius: 40rpx;
	}

	.border_radius_normal {
		border-radius: 30rpx;
	}

	.border_radius_l {
		border-radius: 20rpx;
	}

	.border_radius_m {
		border-radius: 13rpx;
	}

	.border_radius_s {
		border-radius: 6rpx;
	}

	/****************padding******************/
	// 垂直
	.padding_tb_xxl {
		padding: 50rpx 0;
	}

	.padding_tb_xl {
		padding: 40rpx 0;
	}

	.padding_tb_normal {
		padding: 30rpx 0;
	}

	.padding_tb_l {
		padding: 20rpx 0;
	}

	.padding_tb_s {
		padding: 10rpx 0;
	}

	.padding_tb_m {
		padding: 5rpx 0;
	}

	// 水平
	.padding_rl_xxl {
		padding: 0 50rpx;
	}

	.padding_rl_xl {
		padding: 0 40rpx;
	}

	.padding_rl_normal {
		padding: 0 30rpx;
	}

	.padding_rl_l {
		padding: 0 20rpx;
	}

	.padding_rl_m {
		padding: 0 10rpx;
	}

	.padding_rl_s {
		padding: 0 5rpx;
	}

	// 单边
	.padding_top_xl {
		padding-top: 40rpx;
	}

	.padding_top_normal {
		padding-top: 30rpx;
	}

	.padding_top_l {
		padding-top: 20rpx;
	}

	.padding_top_m {
		padding-top: 10rpx;
	}

	.padding_top_s {
		padding-top: 6rpx;
	}

	.padding_bottom_xl {
		padding-bottom: 40rpx;
	}

	.padding_bottom_normal {
		padding-bottom: 30rpx;
	}

	.padding_bottom_l {
		padding-bottom: 20rpx;
	}

	.padding_bottom_m {
		padding-bottom: 10rpx;
	}

	.padding_bottom_s {
		padding-bottom: 6rpx;
	}

	.padding_right_xl {
		padding-right: 40rpx;
	}

	.padding_right_normal {
		padding-right: 30rpx;
	}

	.padding_right_l {
		padding-right: 20rpx;
	}

	.padding_right_m {
		padding-right: 10rpx;
	}

	.padding_right_s {
		padding-right: 6rpx;
	}

	.padding_left_xl {
		padding-left: 40rpx;
	}

	.padding_left_normal {
		padding-left: 30rpx;
	}

	.padding_left_l {
		padding-left: 20rpx;
	}

	.padding_left_m {
		padding-left: 10rpx;
	}

	.padding_left_s {
		padding-left: 6rpx;
	}

	/****************margin******************/
	// 垂直
	.margin_tb_xxl {
		margin: 50rpx 0;
	}

	.margin_tb_xl {
		margin: 40rpx 0;
	}

	.margin_tb_normal {
		margin: 30rpx 0;
	}

	.margin_tb_l {
		margin: 20rpx 0;
	}

	.margin_tb_s {
		margin: 10rpx 0;
	}

	.margin_tb_m {
		margin: 5rpx 0;
	}

	// 水平
	.margin_rl_xxl {
		margin: 0 50rpx;
	}

	.margin_rl_xl {
		margin: 0 40rpx;
	}

	.margin_rl_normal {
		margin: 0 30rpx;
	}

	.margin_rl_l {
		margin: 0 20rpx;
	}

	.margin_rl_m {
		margin: 0 10rpx;
	}

	.margin_rl_s {
		margin: 0 5rpx;
	}

	// 单边
	.margin_top_xl {
		margin-top: 40rpx;
	}

	.margin_top_normal {
		margin-top: 30rpx;
	}

	.margin_top_l {
		margin-top: 20rpx;
	}

	.margin_top_m {
		margin-top: 10rpx;
	}

	.margin_top_s {
		margin-top: 6rpx;
	}

	.margin_bottom_xl {
		margin-bottom: 40rpx;
	}

	.margin_bottom_normal {
		margin-bottom: 30rpx;
	}

	.margin_bottom_l {
		margin-bottom: 20rpx;
	}

	.margin_bottom_m {
		margin-bottom: 10rpx;
	}

	.margin_bottom_s {
		margin-bottom: 6rpx;
	}

	.margin_right_xl {
		margin-right: 40rpx;
	}

	.margin_right_normal {
		margin-right: 30rpx;
	}

	.margin_right_l {
		margin-right: 20rpx;
	}

	.margin_right_m {
		margin-right: 10rpx;
	}

	.margin_right_s {
		margin-right: 6rpx;
	}

	.margin_left_xl {
		margin-left: 40rpx;
	}

	.margin_left_normal {
		margin-left: 30rpx;
	}

	.margin_left_l {
		margin-left: 20rpx;
	}

	.margin_left_m {
		margin-left: 10rpx;
	}

	.margin_left_s {
		margin-left: 6rpx;
	}

	/****************主内容占屏幕百分比******************/
	.com_width_xxl {
		width: 96%;
		margin-left: 2%;
	}

	.com_width_xl {
		width: 94%;
		margin-left: 3%;
	}

	.com_width {
		width: 92%;
		margin-left: 4%;
	}

	.com_width_l {
		width: 88%;
		margin-left: 6%;
	}

	.com_width_m {
		width: 84%;
		margin-left: 8%;
	}

	.com_width_s {
		width: 80%;
		margin-left: 10%;
	}

	/****************文字加粗******************/
	.font_weight_normal {
		font-weight: bold;
	}

	.font_weight_l {
		font-weight: 400;
	}

	/****************flex常用******************/
	.display_flex {
		display: flex;
		align-items: center;
	}

	.display_column {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.space_between {
		justify-content: space-between;
	}

	.flex_wrap {
		flex-wrap: wrap;
	}

	.align_item_start {
		align-items: flex-start;
	}

	.align_item_end {
		align-items: flex-end;
	}

	/****************超出几行省略号******************/
	.overflow {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.overflow_tow {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}


	.wrap {
		flex-wrap: wrap;
	}

	.flex {
		flex: 1;
	}

	.row {
		display: flex;
		flex-direction: row;
	}

	.col {
		display: flex;
		flex-direction: column;
	}

	.left {
		justify-content: flex-start;
	}

	.center {
		justify-content: center;
	}

	.right {
		justify-content: flex-end;
	}

	.grid {
		justify-content: space-between;
	}

	.justify-around {
		justify-content: space-around;
	}

	.justify-evenly {
		justify-content: space-evenly;
	}

	.top {
		align-items: flex-start;
	}

	.middle {
		align-items: center;
	}

	.bottom {
		align-items: flex-end;
	}

	.items-baseline {
		align-items: baseline;
	}

	.items-stretch {
		align-items: stretch;
	}

	.self-top {
		align-self: flex-start;
	}

	.self-center {
		align-self: center;
	}

	.self-bottom {
		align-self: flex-end;
	}

	.self-baseline {
		align-self: baseline;
	}

	.self-stretch {
		align-self: stretch;
	}

	// theme.scss
	$u-font-size-base: 28rpx;

	/* 设置全局字体大小 */
	view,
	text,
	input,
	u-button,
	u-input,
	u-text {
		font-size: 28rpx !important;
	}

	.cc {
		text-align: center;
		padding-top: 60rpx;
	}
</style>